Repository navigation
Define the shared code once in @onload instead of in every block - #23
Merged
Merged
Conversation
LiaScript expands a macro into every slide that uses it. With the whole session logic in the run-once block, every glpython block added about 37k characters, and slides with a choice quiz hung in Chrome when opened directly (e.g. course/?…README.md#18): LiaScript's parser computes the column against the original text, the expansions push it far past the end, the quiz parser builds an indentation regex of ~39k spaces, and V8 throws "Regular expression too large" (Safari's engine accepts it). The session logic is now window.__glpythonMount in @onload. The run-once block only passes its arguments and send; a block that runs before @onload waits in window.__glpythonPending. One expansion is now ~3k characters. check-macro also checks the @onload block. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Slides that use glpython blocks and a choice quiz hang in Chrome on the loading screen when they are opened directly, e.g. Etappe 1 of
glpython-edu/funktionenat…/README.md#18(also after a reload, since LiaScript keeps the slide in the URL). Safari works.Console:
Invalid regular expression: /^ …39408 spaces… /g: Regular expression too large.Cause: LiaScript expands macros into the remaining input, but the parser library computes the column against the original text (
currentLocationinandre-dietrich/parser-combinators). Once the expansions run past the end of the original text, the column is the overshoot. The choice-quiz parser (Quiz/Vector/Parser.elm,item) pushes that many spaces as indentation, and V8 refuses the resulting regex (Safari's engine accepts it). Every glpython block expanded to ~37k characters, 34k of them therun-oncesession logic, so a slide with one or two blocks was enough.Change
window.__glpythonMount(args, send)in the template's@onload, which LiaScript runs once per course (an imported template's@onloadis appended to the course's).run-onceblock only passes["@0" … "@9"]and itssend. A block that runs before@onloadwaits inwindow.__glpythonPending, which@onloadempties.@GLPython.embedgoes from 37,048 to 2,964 characters.check-macroalso checks the@onloadblock (node --check, same line reporting).CLAUDE.md: where the code lives and why it must stay in@onload.The code itself is unchanged, apart from
sessionId,modeand the options coming fromargs.Tested
Headless Chrome, hosted player (
liascript.github.io/course):mainstill fails on P17: «In IDE öffnen ▾» – open the block as a copy in the IDE #18.mainand load with this branch; all slides of Etappe 1 load.Hello World #0…#4), and «Several files» with a library URL (42, same asmain).node scripts/check-macro.mjspasses and catches a syntax error in@onloadwith the right line.Not tested: turtle, Tests, the IDE link, and iPad.
Follow-up
The real bug is in LiaScript; to be reported upstream with a minimal course.
🤖 Generated with Claude Code